package com.luo.search.quartz;

import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class QuartzConfig {
    @Bean
    public JobDetail loadData() {
        return JobBuilder.newJob(QuartzJob.class)
                .withIdentity("loadES")
                .storeDurably()
                .build();
    }

    @Bean
    public Trigger trigger() {
        //每五个小时更新es数据库
        CronScheduleBuilder cron = CronScheduleBuilder.cronSchedule("0 0 0/2 * * ? ");
        return TriggerBuilder.newTrigger()
                .withSchedule(cron)
                .withIdentity("EStrigger")
                .forJob(loadData())
                .build();
    }
}
